/**
 *@module project
 *@name engineeringSupervisionPage
 *@desc 项目管理主页面
 *@author YuXueYing
 *@date 2019-09-09 16:52:27
 */
Ext.define('js.foundation.foundationPageMain', {
    extend: 'Ext.panel.Panel',
    scrollable : true,
    name:'地基验槽',
    id:'js.foundation.foundationPageMain',
    requires: ['js.Util', 'js.ctrl.Common'],
    bodyStyle: "background-color:#eee;",
    config: {
        border: false,
        layout: {
            type: 'vbox',
            align: 'stretch'
        }
    },
    initComponent: function () {
        let params={
            floor_thickness:this.floor_thickness,
            indoor_space_size:this.indoor_space_size,
            engineering_id:this.engineering_id,
            engineering_no:this.engineering_no,
            engineering_name:this.engineering_name,
            Zstsatus:this.Zstsatus,
            status:this.status,
            PageName:this.PageName,
            storeAll:this.storeAll,
        };
        let information = Ext.create('Ext.Component',
            {
                id:'informationA',
                html:'<div style="height:36px;background:#fff;box-shadow: #666 0px 0px 10px;">' +
                '<div style="float: left" id="EngineeringSupervision">' +
                '<div style="width:100%;font-size: 14px;margin-top: 11px;margin-left:30%;display:inline-block; color: #000;"><span>工程管理</span></div>' +
                '</div>' +
                '<div style="float: left">' +
                '<div style="width:100%;font-size: 14px;margin-top: 11px;margin-left:478%;display:inline-block; color: #000;"><span>></span></div>' +
                '</div>' +
                '<div style="float: left" id="gcjd">' +
                '<div style="width:100%;font-size: 14px;margin-top: 11px;margin-left:50;display:inline-block; color: #000;"><span id="titlename">工程进度验收节点</span></div>' +
                '</div>' +
                '<div style="float: left">' +
                '<div style="width:100%;font-size: 14px;margin-top: 11px;margin-left:270%;display:inline-block; color: #000;"><span>></span></div>' +
                '</div>' +
                '<div style="float: left">' +
                '<div style="width:100%;font-size: 14px;margin-top: 11px;margin-left:35;display:inline-block; color: #000;"><span id="titlename">'+this.titleName+' </span></div>' +
                '</div>' +
                '</div>'
            });
        let informationNameComponent={
            xtype: 'panel',
            margin: '20 0 0 30',
            bodyStyle: "background-color:#eee;",
            items:[{
                xtype:'panel',
                margin: '24 100% -10 30',
                html: '<span id="enterprise_nameA" style="font-size: 20px;font-weight: bold; width:"80%";display:inline-block;font-family: 方正兰亭黑;color:#000">'+this.engineering_no+' ----- '+this.engineering_name+'</span>'

            },{
                xtype : "button",
                height:'40',
                cls:'buttonAAWancheng',
                handler: this.wancheng,
                progress_type:this.status,
                engineering_id:this.engineering_id,
                engineering_no:this.engineering_no,
                engineering_name:this.engineering_name,
                storeAll:this.storeAll,
                width: '100',
                text:'完成'
            },{
                xtype : "button",
                height:'40',
                cls:'buttonAA',
                id:'enterprise_nameA',
                handler: this.fanhui,
                engineering_id:this.engineering_id,
                engineering_no:this.engineering_no,
                engineering_name:this.engineering_name,
                width: '100',
                text:'返回'
            }]
        };
/*        let titleAddPage= Ext.create('js.foundation.TitleAddPanel', params);*/
        let engineeringSupervisionShowPage = Ext.create(this.FoundationShowBg, params);
        this.items = [information,informationNameComponent,/*titleAddPage*/engineeringSupervisionShowPage];
        this.callParent(arguments);
        this.on('afterrender',this.goBack);

    },
    goBack:function () {
//点击工程管理删除两个地基检验 以及工程进度验收节点
        Ext.get("EngineeringSupervision").on("click",function(){
            util.sysPanelAdd('js.project.engineeringSupervisionPage');
            let removelist = ['js.information.InformationListMain','js.foundation.foundationPageMain'];
            for(let i in removelist){
                let cmp = Ext.getCmp(removelist[i]);
                if (cmp) cmp.close();
                if (cmp) cmp.remove(cmp)
            }
        });
        let engineering_id=this.engineering_id;
        let engineering_no=this.engineering_no;
        let engineering_name=this.engineering_name;
        Ext.get("gcjd").on("click",function(){
            let newPanel=Ext.getCmp('js.information.InformationListMain');
            if(newPanel){
                newPanel.close();
            }

            util.sysPanelAdd('js.information.InformationListMain',{
                engineering_id:engineering_id,
                engineering_no:engineering_no,
                num:1,
                engineering_name:engineering_name
            });
            let removelist = ['js.foundation.foundationPageMain'];
            for(let i in removelist){
                let cmp = Ext.getCmp(removelist[i]);
                if (cmp) cmp.close();
                if (cmp) cmp.remove(cmp)
            }
        });


    },
    fanhui:function (btn) {
        let newPanel=Ext.getCmp('js.information.InformationListMain');
        if(newPanel){
            newPanel.close();
        }
        let engineering_id=btn.engineering_id;
        let engineering_no=btn.engineering_no;
        let engineering_name=btn.engineering_name;
        util.sysPanelAdd('js.information.InformationListMain',{
            engineering_id:engineering_id,
            engineering_no:engineering_no,
            num:1,
            engineering_name:engineering_name
        });
        let removelist = ['js.foundation.foundationPageMain'];
        for(let i in removelist){
            let cmp = Ext.getCmp(removelist[i]);
            if (cmp) cmp.close();
            if (cmp) cmp.remove(cmp)
        }
    },
    wancheng:function(btn){
        let progress_type=btn.progress_type;
        let engineering_id=btn.engineering_id;
        let engineering_no=btn.engineering_no;
        let engineering_name=btn.engineering_name;
        let vim={
            xtype:'panel',
            bodyPadding: '80 0 0 120',
            defaultType: 'textfield',
            html:'<span style="font-size: 26px;font-weight: normal;letter-spacing: 1px;color: #2672d9;">您确定完成当前步骤吗？</span>',
            dockedItems: [{
                dock: 'bottom',
                xtype: 'toolbar',
                ui: 'fuck',
                height:100,
                items: [{
                    xtype: 'button',
                    cls:'tuichu',
                    text: `<span style="color:#fff">取消</span>`,
                    margin: '0 0 0 100',
                    scale: 'medium',
                    handler: function (btn) {
                        btn.up('window').close();
                    },
                }, {
                    xtype: 'button',
                    // scale: 'user',
                    arrow: true,
                    cls: 'tuichuA',
                    text: `<span style="color:#fff">确定</span>`,
                    scale: 'medium',
                    margin: '0 125 0 30',
                    scope: this,
                    handler: function(btn){
                        util.post('/progressRoutes', {
                            action_type:'progressQuery',
                            progress_type:progress_type,
                            engineering_id:engineering_id
                        }).then(function (response) {
                            let obj= Ext.decode(response.responseText);
                           if(obj.data.length<=0){
                               Ext.toast(`请输入数据`);
                               btn.up('window').close();
                           }else{
                               util.post('/progressRoutes', {
                                   action_type:'progressFinish',
                                   progress_type:progress_type,
                                   engineering_id:engineering_id
                               }).then(function (response) {
                                   let obj= Ext.decode(response.responseText);
                                   if(obj.success){
                                       btn.up('window').close();
                                       Ext.toast('成功');
                                       let newPanel=Ext.getCmp('js.information.InformationListMain');
                                       if(newPanel){
                                           newPanel.close();
                                       }
                                       util.sysPanelAdd('js.information.InformationListMain',{
                                           engineering_id:engineering_id,
                                           engineering_no:engineering_no,
                                           num:1,
                                           engineering_name:engineering_name
                                       });


                                   }else{
                                       Ext.toast(`<div style="font-size:28px;">保存失败,${obj.message}</div>`);
                                   }
                               });
                           }
                        });
                    }
                }]
            }]
        }
        let winS = util.window(vim, {title: '完成' ,height: '290', width: '500'});
        winS.show();
    }
});